<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="com.tjsinfo.tjsoa.fileExpress.vo.FileExpressFile"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
ResourceBundle bundle = ResourceBundle.getBundle("com.tjsinfo.tjsoa.fileExpress.properties.FileExpress");
String fileUploadPath = bundle.getString("fileupload");
fileUploadPath = fileUploadPath.replace("\\","\\\\");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet1" type="text/css" id="txlz7"/>
	
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
	<link href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all-debug.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
	<style type="text/css">
			td {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
			th {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
         .trBgColor { background-color:#A4D7E8; cursor: hand;}
         
         .blist {
		    background-image: url(<%=basePath%>addresslist/images/m_icon06.gif) !important;
		}
		
		.bmenu {
		    background-image: url(<%=basePath%>addresslist/images/m_icon07.gif) !important;
		}
		.bxinjian {
		    background-image: url(<%=basePath%>addresslist/images/m_icon10.gif) !important;
		}
		.black_overlays{
			display: none;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: #C1EBFC;
			z-index:1002;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=30);
		}
		.insertGroup {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		
		.window {
	DISPLAY: none;
	LEFT: 300px;
	OVERFLOW: hidden;
	WIDTH: 500px;
	POSITION: absolute;
	TOP: 100px;
	HEIGHT: 200px
}

.windowTop {
	BACKGROUND-POSITION: right top;
	BACKGROUND-IMAGE: url(<%=basePath%>fileExpress/images/window_top_end.png);
	OVERFLOW: hidden;
	CURSOR: move;
	BACKGROUND-REPEAT: no-repeat;
	POSITION: relative;
	HEIGHT: 30px
}

.windowTopContent {
	BACKGROUND-POSITION: left top;
	FONT-WEIGHT: bold;
	FONT-SIZE: 14px;
	BACKGROUND-IMAGE: url(<%=basePath%>fileExpress/images/window_top_start.png);
	OVERFLOW: hidden;
	COLOR: #206D85;
	TEXT-INDENT: 10px;
	LINE-HEIGHT: 30px;
	MARGIN-RIGHT: 13px;
	BACKGROUND-REPEAT: no-repeat;
	FONT-FAMILY: Arial, Helvetica, sans-serif;
	HEIGHT: 30px
}
#windowBottom {
	BACKGROUND-POSITION: right bottom;
	BACKGROUND-IMAGE:
		url(<%=basePath%>fileExpress/images/window_bottom_end.png);
	BACKGROUND-REPEAT: no-repeat;
	POSITION: relative;
	HEIGHT: 370px
}

.windowBottomContent {
	BACKGROUND-POSITION: left bottom;
	BACKGROUND-IMAGE:
		url(<%=basePath%>fileExpress/images/window_bottom_start.png);
	MARGIN-RIGHT: 13px;
	BACKGROUND-REPEAT: no-repeat;
	POSITION: relative;
	HEIGHT: 370px
}

.windowResize {
	RIGHT: 3px;
	CURSOR: se-resize;
	BOTTOM: 5px;
	POSITION: absolute
}

#windowClose {
	RIGHT: 10px;
	CURSOR: pointer;
	POSITION: absolute;
	TOP: 10px
}

.windowContent {
	BORDER-RIGHT: #6caf00 1px solid;
	BORDER-TOP: #6caf00 1px solid;
	FONT-SIZE: 11px;
	LEFT: 10px;
	OVERFLOW: auto;
	BORDER-LEFT: #6caf00 1px solid;
	WIDTH: 475px;
	MARGIN-RIGHT: 15px;
	BORDER-BOTTOM: #6caf00 1px solid;
	FONT-FAMILY: Arial, Helvetica, sans-serif;
	POSITION: absolute;
	TOP: 30px;
	HEIGHT: 150px;
	BACKGROUND-COLOR: #fff
}
	</style>
    <script type='text/javascript' src='<%=basePath%>dwr/interface/FileExpressFileBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	<%
		List<FileExpressFile> list = (List<FileExpressFile>)request.getAttribute("list");
		int pagecount = 0;
		if(list.size() != 0){
			pagecount = list.size();
		}
		String listUser_id = (String)request.getAttribute("listUser_id");
		if(listUser_id == null)listUser_id = "-1";
		String dirName = request.getSession().getServletContext().getRealPath("/");
		dirName = dirName.replace("\\","\\\\");
		String downUrlFileSize = bundle.getString("downUrlFileSize");
	 %>
	 <script language="JavaScript" type="text/javascript" >//最大数据量
var total="<%=pagecount %>";
//每页的显示量
var pagesize="17";
//一共有多少页
var pagenum=Math.ceil(total/pagesize);
//生成导航
var nowpage = 1;
function initpage(nowpage){
var pagenav='<a>共'+total+'条,共'+pagenum+'页&nbsp;&nbsp;当前为'+nowpage+'页</a>&nbsp;&nbsp; <a>跳转到';
pagenav += '<select onchange="goToPage(this.value);">';
for(i=1;i<=pagenum;i++){
	if(i==nowpage){
		pagenav += '<option value="'+i+'" selected="selected">'+i+'</option>';
	}else{
		pagenav += '<option value="'+i+'">'+i+'</option>';
	}
}
pagenav += '</select>页</a>';
if(pagenum != 0){
document.getElementById('page').innerHTML=pagenav;
}
}
//翻页
function goToPage(page){
var start=(page-1)*pagesize;
var max=page*pagesize;
for(vs=0;vs<total;vs++){
var obj=document.getElementById('item_' + vs);
obj.style.display="none";
}
if(max>total)max=total;
for(v=start;v<max;v++){
var obj=document.getElementById('item_' + v);
obj.style.display="block";
}
initpage(page);
}
//上一页
function up(nowpage){
if(nowpage>1)goToPage((nowpage-1));
}
//下一页
function down(nowpage){
if(nowpage<pagenum)goToPage((nowpage+1));
}
var intpage = 1;
		
function init(){
	window.parent.frames.mainFrame.location.reload();
}

function shaodeng(){
	document.getElementById("shaodeng").style.top = document.body.clientHeight/3;
	document.getElementById("shaodeng").style.left = document.body.clientWidth/3;
	document.getElementById("shaodeng").style.display = "block";
	document.getElementById("blackdiv").style.display = "block";
}

window.onload = function(){
	document.getElementById("right").style.width = document.body.clientWidth-5;
	initpage(1);
	var tb = new Ext.Toolbar(
		{
			height:25
		}
	);

    tb.render('menu');
    tb.add(
    {
            text:'返回',
            iconCls: 'daohang',
        	handler: function(){
        		location.href="<%=basePath%>tjsinfo/tjsoa/fileExpress/loginFileExpress.do";
			}
    }
    );
	tb.addFill();
    tb.addText('<img id="windowResize" src="<%=basePath%>images/m_icon05.gif;"><a style="font-weight:bold; color:black;line-height: 22px;">查询结果</a>&nbsp;&nbsp;&nbsp;');
}
</script>
  </head>
  
  <body>
  <div id="right" style="z-index: 19;height: 98%">
	<div id="menu" style="padding-top:4px;"></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
      	<tr>
            <td width="100%" valign="top" height="100%">
               <div class="contab" style="height: 90%;width: 100%;margin-left: 0px;">
                  <table class="p_06" width="100%" border="0" cellspacing="0" id="mytable">
                    <tr align="center">
                        <th width="24%" style="text-align: center;">文件名称</th>
                        <th width="12%" style="text-align: center;">发送人</th>
                        <th width="12%" style="text-align: center;">发送时间</th>
                        <th width="10%" style="text-align: center;">大小</th>
                        <th width="6%" style="text-align: center;">备注</th>
                        <th width="15%" style="text-align: center;">文件夹</th>
                        <th width="10%" style="text-align: center;">下载</th>
                    </tr>
                    <%
                    	int i = 0;
                    	SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
                    	for (FileExpressFile listUser : list) {
                    	String id = listUser.getId().toString();
                    	String fileName = listUser.getFileName();
                    	if(fileName != null && !"".equals(fileName)){
                    		if(fileName.length()>11)fileName=fileName.substring(0,11);
                    	}
				
                    	String fasong = listUser.getTjsUser().getUserName();
                    	String fasong1 = fasong;
	                    if(fasong.length()>5){
	                    	fasong=fasong.substring(0,5);
	                    }
                    	String datetime = "";
                    	String datetime1 = "";
                    	if(listUser.getDatetime() != null){
                    		datetime = sdf.format(listUser.getDatetime());
                    		datetime1 = datetime;
                    	}else{
                    		datetime="";datetime1="";
                    	}
                    	double fileSize = listUser.getFileSize();
                    	String size = "";
                    	if(fileSize>1048576){
                    		size = new DecimalFormat("###,###,###.##").format(fileSize/1048576)+"M"; 
                    	}else{
                    		size = new DecimalFormat("###,###,###.#").format(fileSize/1024)+"KB";
                    	}
		
                    	String beizhu = listUser.getRemark();
                    	String beizhu1 = "";
                    	if(beizhu == null || "".equals(beizhu)){
                    		beizhu = "无";
                    		beizhu1 = "无备注";	
                    	}else{
                    		beizhu = "备注";
                    		beizhu1 = listUser.getRemark();
                    	}
                    	String groupName = listUser.getFileExpressGroup().getGroupName();
                    	String groupName1 = groupName;
                    	if(groupName.length()>8)groupName=groupName.substring(0,8);
					%>
					<tr onmouseover='this.className="trBgColor"' onmouseout='this.className=""' id="item_<%=i %>">
						<td><a title="<%=listUser.getFileName() %>" href="javaScript:downloadfile('<%=id %>','<%=listUser.getFileName() %>','<%=listUser.getFileSize() %>');"><%=fileName %></a></td>
						<td><a title="<%=fasong1 %>"><%=fasong %></a></td>
						<td><a title="<%=datetime1 %>"><%=datetime %></a></td>
						<td><a title="<%=size %>"><%=size %></a></td>
						<td id="beizhuid<%=i %>"><a title="<%=beizhu1 %>" onclick="javascript:beizhuxian('<%=beizhu1 %>',<%=i %>);"><%=beizhu %></a></td>
						<td><a title="<%=groupName1 %>"><%=groupName %></a></td>
						<td><a href="javaScript:downloadfile('<%=id %>','<%=listUser.getFileName() %>','<%=listUser.getFileSize() %>');">下载</a></td>
					</tr>
					<%
						i++;
						}
                     %>
                      <tr align="center">
                        <td colspan="8">
                          <div class="pages" id="page">
                          </div>
                        </td>
                    </tr>
                 </table>
              </div>
            </td>
          </tr>
      </table>
</div>
<div class="insertGroup" id="shaodeng">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left">
                 <b>请求正在处理中,请稍候....</b>
                 </td>
               </tr>
             </table>
</div>
<div id="blackdiv" class="black_overlays">
	<iframe style="width:100%;height:100%;filter:alpha(opacity=0);-moz-opacity:0"></iframe>
</div>
<input type="hidden" id="beizhuid"/>
<div id="windowdiv" class="window" style="display: none">
			<div id="windowTop" class="windowTop">
				<div id="windowTopContent" class="windowTopContent">
					文件备注
				</div>
				<img id="windowClose"
					src="<%=basePath%>fileExpress/images/window_close.jpg" onclick="beizhuguan();" class="windowClose"/>
			</div>
			<div id="windowBottom" class="windowBottom">
				<div id="windowBottomContent" class="windowBottomContent" style="width: 500"></div>
			</div>
			<div id="windowContent" style="background: #D9E8F1;" class="windowContent">
				<div style="padding-top: 20px; padding-left: 20px;width: 90%" id="remarkdiv">
				</div>
			</div>
		<img id="windowResize" src="<%=basePath%>fileExpress/images/window_resize.gif" class="windowResize"/>
</div>
<div class="insertGroup" id="fileDownloadDiv">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left" background="<%=basePath%>images/small_07.gif">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
				     <tr>
				         <td width="6%" align="center" style="padding-top:3px;"><img src="images/icon_06.gif" /></td>
				         <td width="88%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">下载文件（如下载有误，请右键单击"下载"—>"目标另存为"进行操作）</td>
				         <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiFileDownloadDiv();"
											style="cursor: hand" />
							</div>
						</td>
				     </tr>
				</table>
                 </td>
               </tr>
                <tr>
                 <td height="109" class="zz">
                     <table width="90%" height="80%" border="0" cellspacing="0" cellpadding="0" class="researchtab">
                     <tr>
                      <td align="center" colspan="2"><div id="xiazaidiv"></div></td>
                      </tr>
                      <tr>
                      <td align="right"><a id="filedown" onclick="xiaoshiFileDownloadDiv();">下载</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                      <td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javaScript:xiaoshiFileDownloadDiv();">返回</a></td>
                      </tr>
                    </table>
                 </td>
               </tr>
             </table>
</div>
  </body>
  <script>
for(vs=1;vs<total;vs++){
	var obj=document.getElementById('item_' + vs);
	obj.style.display="none";
	for(v=1;v<pagesize;v++){
		if(vs==v){
			var obj=document.getElementById('item_' + vs);
			obj.style.display="block";
		}
	}
}
function getXY(Obj) {
			var sumTop = 0, sumLeft = 0;
			while(Obj != document.body){
			sumLeft += Obj.offsetLeft;sumTop += Obj.offsetTop;Obj = Obj.offsetParent;
			} 
			return {x:sumLeft, y:sumTop};
		}
		
		function beizhuxian(remark,i){
			var pageselect = document.getElementById('page');
	 		pageselect.style.display = "none";
			var windowdiv = document.getElementById("windowdiv");
			if(windowdiv.style.display != 'none') {
				beizhuguan();
			}
			if(windowdiv.style.display == 'none') {
				document.getElementById("item_"+i+"").className="trBgColor";
				document.getElementById("item_"+i+"").onmouseout = '';
				var beizhudiv = document.getElementById("beizhuid"+i+"");
				var Objxy=getXY(beizhudiv);
				
				var topzhu = windowdiv.style.top;
				var h = document.body.offsetHeight;
				if(h-Objxy.y>200){
					windowdiv.style.top = Objxy.y+23;
				}else{
					windowdiv.style.top = Objxy.y-200;
				}
				windowdiv.style.left = Objxy.x-350;
				document.getElementById('remarkdiv').innerHTML=remark;
				document.getElementById('beizhuid').value=i;
				windowdiv.style.display = 'block';
			}
		}
		
		function beizhuguan(){
			var pageselect = document.getElementById('page');
	 		pageselect.style.display = "block";
			var i = document.getElementById('beizhuid').value;
			
			var beizhudiv = document.getElementById("beizhuid"+i+"");
			var Objxy=getXY(beizhudiv);
			
			var b = document.getElementById('item_'+i+'');
			b.onmouseout=function(){this.className='';};
			document.getElementById("item_"+i+"").className=null;
			var windowOpendiv = document.getElementById("windowdiv");
			windowdiv.style.display = 'none';
		}
		
		function downloadfile(id,filename,fileSize){
			FileExpressFileBo.downloadFile(id,filename,'<%=fileUploadPath %>',{
				callback:function(str) {
					document.getElementById("blackdiv").style.display = "block";
					document.getElementById("fileDownloadDiv").style.top = document.body.clientHeight/4;
					document.getElementById("fileDownloadDiv").style.left = document.body.clientWidth/5;
					document.getElementById("fileDownloadDiv").style.display = "block";
					document.getElementById("xiazaidiv").innerHTML = '您现在要下载的文件是:'+filename.split("@&_&@")[1];
					var path = '<%=fileUploadPath %>';
					path += str+'/download/'+filename.split("@&_&@")[1];
					var downUrlFileSize = <%=downUrlFileSize %>;
					document.getElementById("filedown").href='<%=basePath %>tjsinfo/tjsoa/fileExpress/ioAction.do?id='+id+'';
				}
			}
			);
		}
		
		function xiazai(path){
			document.execCommand('Saveas',false,''+path+'');
		}
		function xiaoshiFileDownloadDiv(){
			document.getElementById("fileDownloadDiv").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
</script>
</html>
